using System.Collections.Generic;
using PropertyExpression.TypedDataBinding.Web.Example.Exapmle1.Model;

namespace PropertyExpression.TypedDataBinding.Web.Example.Exapmle1.Model
{
    public class B : IdOwner
    {
        public B(int id)
            : base(id)
        {
        }

        private int aId;

        public B(int id, int aId) : base(id)
        {
            this.aId = aId;
        }

        public int AId
        {
            get { return aId; }
            set { aId = value; }
        }

        public A A
        {
            get
            {
                return DataFactory.Instance.GetById<A>(AId);
            }
        }

        public IEnumerable<C> Cs
        {
            get
            {
                foreach (C c in DataFactory.Instance.GetAll<C>())
                {
                    if (c.BId == Id)
                    {
                        yield return c;
                    }
                }
            }
        }
    }
}